package com.lixixi.tingshu.user.api;

import com.lixixi.tingshu.common.anno.NeedLogin;
import com.lixixi.tingshu.common.result.Result;
import com.lixixi.tingshu.user.service.UserPaidTrackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/user/userInfo")
public class UserInfoApiController {

	@Autowired
	UserPaidTrackService userPaidTrackService;

	@PostMapping("/userIsPaidTrack/{albumId}")
	@NeedLogin(isLogin = false)
	Result<Map<Long, Integer>> userIsPaidTrack(@PathVariable("albumId") Long albumId,  @RequestBody List<Long> trackIdList) {
		Map<Long, Integer> resultMap = userPaidTrackService.judgeUserIsPaidTrack(albumId, trackIdList);
		return Result.ok();
	}

	// http://127.0.0.1/api/user/userInfo/isSubscribe/380
	@GetMapping("/isSubscribe/{albumId}")
	Result isSubscribe(@PathVariable("albumId") Long albumId) {

		return Result.ok();
	}

	@GetMapping("/api/user/userInfo/userIsPaidTrackIdList/{albumId}")
	@NeedLogin(isLogin = false)
	Result<List<Long>> userIsPaidTrackIdList(@PathVariable("albumId") Long albumId){
		List<Long> paidTrackIdList = userPaidTrackService.getPaidTrackIdList(albumId);
		return Result.ok(paidTrackIdList);
	}

}
